import {get, post} from './axios'


// 获取后台会员列表
async function getUserList(data) {
    const url = `/admin/adminuser/list`
    return await post(url, data)
}
// 登入
async function login(data) {
    const url = `/admin/visitor/login`
    return await post(url, data)
}
// 退出登陆
async function logout(data) {
    const url = `/admin/visitor/logout`
    return await get(url, data)
}

// 系统管理api
// 用户列表
async function getUser(data) {
    const url = `/admin/adminuser/list`
    return await post(url, data)
}

// 添加用户
async function addUser(data) {
    const url = `/admin/adminuser/add`
    return await post(url, data)
}

// 编辑用户
async function editUserInfo(data) {
    const url = `/admin/adminuser/edit`
    return await post(url, data)
}

// 删除用户
async function delUserInfo(data) {
    const url = `/admin/adminuser/batchedit`
    return await post(url, data)
}

// 权限规则管理
// 规则列表
async function rulesList(data) {
    const url = `/admin/authrule/list`
    return await get(url, data)
}

// 添加规则
async function addRules(data) {
    const url = `/admin/authrule/add`
    return await get(url, data)
}

// 编辑规则
async function editRules(data) {
    const url = `/admin/authrule/edit`
    return await post(url, data)
}

// 删除规则
async function delRulesInfo(data) {
    const url = `/admin/authrule/batchedit`
    return await post(url, data)
}

// 权限组列表
async function authGroupList(data) {
    const url = `/admin/authgroup/list`
    return await get(url, data)
}

// 获取规则节点
async function getNode(data) {
    const url = `/admin/authrule/getNode`
    return await get(url, data)
}

// 添加权限组
async function addAuthGroup(data) {
    const url = `/admin/authgroup/add`
    return await post(url, data)
}

// 编辑权限组
async function editAuthGroup(data) {
    const url = `/admin/authgroup/edit`
    return await post(url, data)
}

// 删除权限组
async function delAuthGroup(data) {
    const url = `/admin/authgroup/batchedit`
    return await post(url, data)
}

// 根据用户id获取权限分组
async function getGroupByUid(data) {
    const url = `/admin/authgroup/getgroupbyuid`
    return await get(url, data)
}

// 根据用户id获取权限分组
async function setGroupByUid(data) {
    const url = `/admin/authgroup/setgroupbyuid`
    return await post(url, data)
}

export {
    getUserList,
    login,
    logout,
    getUser,
    addUser,
    editUserInfo,
    delUserInfo,
    rulesList,
    addRules,
    editRules,
    delRulesInfo,
    authGroupList,
    getNode,
    addAuthGroup,
    editAuthGroup,
    delAuthGroup,
    getGroupByUid,
    setGroupByUid
}
